package cn.itsource.xhy.config;

import cn.itsource.xhy.basic.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebInterceptorConfig implements WebMvcConfigurer{

    @Autowired
    private LoginInterceptor loginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**") // 拦截名单
                .excludePathPatterns("/user/login") // 放行名单
                .excludePathPatterns("/emp/login") // 放行名单
                .excludePathPatterns("/code/sendCode") // 放行名单
                .excludePathPatterns("/searchMasterMsg/**") // 放行名单
                .excludePathPatterns("/fastDfs/upload") // 放行名单
                .excludePathPatterns("/shop/settlement") // 放行名单
                .excludePathPatterns("/pet/front") // 放行名单
                .excludePathPatterns("/pet/detail/**") // 放行名单
                .excludePathPatterns("/pro/**") // 放行名单
                .excludePathPatterns("/pay/**") // 放行名单
                .excludePathPatterns("/user/register"); // 放行名单
    }
}
